<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Procedural PECL/rrd example</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="rrd.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="rrd.examples-oop.html">OOP PECL/rrd example</a></div>
 <div class="up"><a href="rrd.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="rrd.examples-procedural" class="section">
  <h2 class="title">Procedural PECL/rrd example</h2>
  <p class="para">
   <div class="example" id="example-4404">
    <p><strong>Example #1 Procedural usage of rrd</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$rrdFile&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"/speed.rrd"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//create&nbsp;rrd&nbsp;file<br /></span><span style="color: #0000BB">rrd_create</span><span style="color: #007700">(</span><span style="color: #0000BB">$rrdFile</span><span style="color: #007700">,<br />&nbsp;array(<br />&nbsp;&nbsp;</span><span style="color: #DD0000">"--start"</span><span style="color: #007700">,</span><span style="color: #0000BB">920804400</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">"DS:speed:COUNTER:600:U:U"</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">"RRA:AVERAGE:0.5:1:24"</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">"RRA:AVERAGE:0.5:6:10"<br />&nbsp;&nbsp;</span><span style="color: #007700">)<br />);<br /><br /></span><span style="color: #FF8000">//update&nbsp;rrd&nbsp;file<br /></span><span style="color: #0000BB">rrd_update</span><span style="color: #007700">(</span><span style="color: #0000BB">$rrdFile</span><span style="color: #007700">,<br />&nbsp;array(<br />&nbsp;&nbsp;</span><span style="color: #DD0000">"920804700:12345"</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">"920805000:12357"<br />&nbsp;&nbsp;</span><span style="color: #007700">)<br />);<br /><br /></span><span style="color: #FF8000">//graph&nbsp;output<br /></span><span style="color: #0000BB">rrd_graph</span><span style="color: #007700">(</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"/speed.png"</span><span style="color: #007700">,<br />&nbsp;array(<br />&nbsp;&nbsp;</span><span style="color: #DD0000">"--start"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"920804400"</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">"--end"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"920808000"</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">"--vertical-label"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"m/s"</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">"DEF:myspeed=</span><span style="color: #0000BB">$rrdFile</span><span style="color: #DD0000">:speed:AVERAGE"</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">"CDEF:realspeed=myspeed,1000,*"</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">"LINE2:realspeed#FF0000"<br />&nbsp;</span><span style="color: #007700">)<br />);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="rrd.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="rrd.examples-oop.html">OOP PECL/rrd example</a></div>
 <div class="up"><a href="rrd.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
